using System;
using BowlingGame;
using NUnit.Framework;

namespace TestBowlingGame {
    
    [TestFixture]
    public class TestGame 
    {
        
        [Test]
        public void GameScoreIs0_WhenAllTheThrowsInTheGutter() 
        {    
            //Arrange
            Game testee = new Game();

            //Act
            for (int i = 0; i < 20; i++)
            {
                testee.Throw(0);
            }

            //Assert
            Assert.AreEqual(0, testee.Score());
        }

        [Test]
        public void GameScoreIs20_WhenAllTheThrowsKicksOnePin()
        {
            //Arrange
            Game testee = new Game();

            //Act
            for (int i = 0; i < 20; i++)
            {
                testee.Throw(1);
            }

            //Assert
            Assert.AreEqual(20, testee.Score());
        }

        [Test]
        public void GameScoreIs78_WhenAllTheThrowsRandomlyKicksPins()
        {
            //Arrange
            Game testee = new Game();

            //Act
            testee.Throw(8);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(0);
            testee.Throw(4);
            testee.Throw(3);
            testee.Throw(2);
            testee.Throw(7);
            testee.Throw(3);
            testee.Throw(6);
            testee.Throw(4);
            testee.Throw(5);
            testee.Throw(7);
            testee.Throw(0);
            testee.Throw(2);
            testee.Throw(5);
            testee.Throw(6);
            testee.Throw(1);
            testee.Throw(2);
            testee.Throw(3);

            //Assert
            Assert.AreEqual(78, testee.Score());
        }

        [Test]
        public void GameScore_WhenOneSpareOnePointAndOnlyGutters()
        {
            //Arrange
            Game testee = new Game();

            //Act
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(1);
            for (int i = 0; i < 17; i++)
            {
                testee.Throw(0);
            }

            //Assert
            Assert.AreEqual(12, testee.Score());
        }

        [Test]
        public void GameScore_WhenOnlySpares()
        {
            //Arrange
            Game testee = new Game();

            //Act
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(9);
            testee.Throw(1);
            testee.Throw(1);
           
            //Assert
            Assert.AreEqual(182, testee.Score());
        }

        [Test]
        public void GameScore_WhenOneStrike2PointsAndOnlyGutters()
        {
            //Arrange
            Game testee = new Game();

            //Act
            testee.Throw(10);
            testee.Throw(1);
            testee.Throw(1);
            for (int i = 0; i < 17; i++)
            {
                testee.Throw(0);
            }

            //Assert
            Assert.AreEqual(14, testee.Score());
        }

        [Test]
        public void GameScore_WhenOnlyStrikes()
        {
            //Arrange
            Game testee = new Game();

            //Act
            for (int i = 0; i < 22; i++)
            {
                testee.Throw(10);
            }

            //Assert
            Assert.AreEqual(300, testee.Score());
        }

    }
}
